<?php

class city extends basis
{
	function index(){
		//$this -> display('admin/content/scenery.html');
		$id = $this->spArgs("id");
		$type = $this->spArgs("type");
        $conditions = array( 'used' => 1 );
        $t_chain = spClass('chain');
        $this->keywords = $t_chain->findAll($conditions);
//        dump($this->keywords);

        //城市
        $cityinfo = spClass('lib_cityinfo');
        $this->cityinfo =$cityinfo->findAll(array("pid"=>1));
       // dump( $this->cityinfo);
		if($type == 'scenery'){
		   $conditions = array( 'cityid' => $id );
		   $user = spClass('sceneryinfo'); 
	       $this->results = $user->findAll($conditions,"id desc");  // 分页
         //   dump($this->results);
	       $this -> display('city_scenery.html'); // 城市列出
	    }
	    elseif($type == 'lines')
	    {
           $conditions = array( 'cityid' => $id );
		   $user = spClass('linesinfo'); 
	       $this->results = $user->findAll($conditions,"id desc");  // 分页
	       $this -> display('city_lines.html'); // 城市列出
	    }
	}

	function xiamen(){
		$id = $this->spArgs("id");
		$tag = $this->spArgs("tag");

	    $conditions = array( 'used' => 1 );
		$t_chain = spClass('chain');
		$this->keywords = $t_chain->findAll($conditions);
       // dump($this->keywords);
        //城市
        $cityinfo = spClass('lib_cityinfo');
        $this->cityinfo =$cityinfo->findAll(array("pid"=>1));
      //  dump( $this->cityinfo);
		if(empty($id) && $tag == 'tag'){
            $conditions = array( 'id' => $id );
            $t_chain = spClass('chain');
            $t_show = $t_chain->find($conditions);
            $this->keywordsname = $t_show['keywords'];

            $conditions = "tags like '%".$t_show['keywords']."%'";
            $user = spClass('sceneryinfo');
            $results = $user->findAll($conditions,'id DESC',NULL,"150");
            $this->tags = $results;

            // 当季最佳
			$conditions = array( 'cityid' => 3 );
			$results_bset = $user->findAll($conditions,'hotnumber DESC',NULL,"20"); 
			$this->tags_bset = $results_bset;

			// 人气排行
			$conditions = array( 'cityid' => 3 );
			$results_traffic = $user->findAll($conditions,'clicknumber DESC',NULL,"20"); 
			$this->tags_traffic = $results_traffic;

           // dump($this->tags);
            if($this->tags == null || $this->keywords  == null)
            {
                $this -> display('404.php');
            }
            else
            {

                $this -> display('tag.html'); // 厦门关键词首页
            }

		}
		elseif(empty($id) && $tag == 'lines'){

            $conditions = array( 'used' => 1 );
			$t_chain = spClass('chain'); 
			$this->keywords = $t_chain->findAll($conditions); 
			$this -> display('lines.html'); // 厦门关键词首页
		}
		elseif(!empty($id) && $tag == 'tag' || !empty($id) && $tag == 'day')
		{
			$conditions = array( 'id' => $id );
			$t_chain = spClass('chain'); 
			$t_show = $t_chain->find($conditions); 
			$this->keywordsname = $t_show['keywords'];
            $this->show = $t_show;
//            dump($this->show);
			$conditions = "tags like '%".$t_show['keywords']."%'";
			$user = spClass('sceneryinfo'); 
			$results = $user->findAll($conditions,'id DESC',NULL,"150"); 
			$this->tags = $results;

			if($this->tags == null || $this->keywords  == null)
			{
				$this -> display('404.php');
			}
			else
			{
			    $this -> display('content/tag.html');
		    }
		}
		elseif($tag == 'rank' && $id == 'bset') //当季最佳
		{
			$this->keywordsname = "当季最佳";
            $this->show = $t_show;
//            dump($this->show);
			$conditions = "tags like '%".$t_show['keywords']."%'";
			$user = spClass('sceneryinfo'); 
			$results = $user->findAll($conditions,'hotnumber DESC',NULL,"20"); 
			$this->tags = $results;

			if($this->tags == null || $this->keywords  == null)
			{
				$this -> display('404.php');
			}
			else
			{
			    $this -> display('content/tag.html');
		    }
		}
		elseif($tag == 'rank' && $id == 'traffic') // 人气排行
		{
			$this->keywordsname = "人气排行";
            $this->show = $t_show;
//            dump($this->show);
			$conditions = "tags like '%".$t_show['keywords']."%'";
			$user = spClass('sceneryinfo'); 
			$results = $user->findAll($conditions,'clicknumber DESC',NULL,"20"); 
			$this->tags = $results;

			if($this->tags == null || $this->keywords  == null)
			{
				$this -> display('404.php');
			}
			else
			{
			    $this -> display('content/tag.html');
		    }
		}
		elseif($tag == 'rank' && $id == 'new') // 最新发现
		{
			$conditions = array( 'id' => $id );
			$t_chain = spClass('chain'); 
			$t_show = $t_chain->find($conditions); 
			$this->keywordsname = "最新发现";
            $this->show = $t_show;
//            dump($this->show);
			$conditions = "tags like '%".$t_show['keywords']."%'";
			$user = spClass('sceneryinfo'); 
			$results = $user->findAll($conditions,'id DESC',NULL,"20"); 
			$this->tags = $results;

			if($this->tags == null || $this->keywords  == null)
			{
				$this -> display('404.php');
			}
			else
			{
			    $this -> display('content/tag.html');
		    }
		}
		elseif($tag == 'hot' && $id == 'youji') // 最新
		{
			$conditions = array('cityid' => 3 );
		    $e_youji = spClass('youjiinfo'); 

            //标题栏的所有游戏列表
            $this->youji = $e_youji->spPager($this->spArgs('page', 1), 10)->findAll($conditions,'id DESC',NULL,"20");
            $this->pager = $e_youji->spPager()->getPager();
            //dump( $this->pager);
            if($this->youji == null)
			{
				import(APP_PATH.'/tpl/404.php');exit();
			}
			else
			{
			    $this -> display('youji.html');
		    }
		}
		elseif($tag == 'hot' && $id == 'comment') // 最新
		{
	    	$conditions = array('cityid' => 3 );
		    $e_comment = spClass('commentinfo');
            $this->comment = $e_comment->spPager($this->spArgs('page', 1), 10)->findAll($conditions,'id DESC',NULL,"20");
            $this->pager = $e_comment->spPager()->getPager();
            if($this->comment == null)
			{
				import(APP_PATH.'/tpl/404.php');exit();
			}
			else
			{
			    $this -> display('comment.html');
		    }
		}
		elseif($tag == 'hot' && $id == 'forum') // 最新
		{
	    	$conditions = array('cityid' => 3 );
            $this->info = $info;
		    $e_answers = spClass('answersinfo');
            $this->answers = $e_answers->spPager($this->spArgs('page', 1), 10)->findAll($conditions);
            $this->pager = $e_answers->spPager()->getPager();
            if($this->answers == null)
			{
				import(APP_PATH.'/tpl/404.php');exit();
			}
			else
			{
			    $this -> display('answers.html');
		    }
		}
		elseif(!empty($id) && $tag == 'lines' || !empty($id) && $tag == 'day')
		{
			$conditions = array( 'id' => $id );
			$t_chain = spClass('chain'); 
			$t_show = $t_chain->find($conditions); 
			$this->keywordsname = $t_show['keywords'];
			
			$conditions = "tags like '%".$t_show['keywords']."%'";
			$user = spClass('linesinfo'); 
			$results = $user->findAll($conditions,'id DESC',NULL,"150"); 
			$this->tags = $results;
			if($this->tags == null || $this->keywords  == null)
			{
				$this -> display('404.php');
			}
			else
			{

			    $this -> display('content/lineskeyword.html');
		    }
		}
		else
		{
            //点评
            $commentinfo = spClass('commentinfo');
            $this->commentinfo_result = $commentinfo->findSql("SELECT sceneryinfo.title, sceneryinfo.id AS sid,commentinfo.*  FROM  sceneryinfo , commentinfo WHERE sceneryinfo.id = commentinfo.linkid  order by commentinfo.id DESC LIMIT 0 , 2");
//            dump($this->commentinfo_result);
            //景点
            $sceneryinfo = spClass('sceneryinfo');
            $this->sceneryinfo_result=$sceneryinfo->findAll(null,"id DESC","id,title","0,10");
            //人气景点
            $this->sceneryinfo_result_clicknumber=$sceneryinfo->findAll(null,"clicknumber DESC",null,"0,12");
           // dump($this->sceneryinfo_result_clicknumber);
           // dump($this->sceneryinfo_result);
            //论坛
            $answersinfo =spClass('answersinfo');
            $this->answersinfo_result = $answersinfo->findSql("SELECT sceneryinfo.title, sceneryinfo.id AS sid,answersinfo.*  FROM  sceneryinfo , answersinfo WHERE sceneryinfo.id = answersinfo.linkid  order by answersinfo.id DESC  LIMIT 0 , 7");
            //dump($this->answersinfo_result);
            //旅游动态
            $syshistory = spClass('syshistory');
            $this->syshistory_result = $syshistory->findSql("SELECT syshistory . * , user.uname FROM syshistory, user WHERE syshistory.userid = user.uid  order by syshistory.id DESC  LIMIT 0 , 3");
//            dump($this->syshistory_result);
            //游记
            $youjiinfo = spClass('youjiinfo');
//            $this->youjiinfo_result_top=$youjiinfo->findAll(null,null,null,"0,2");
            $this->youjiinfo_result_top=$youjiinfo->findAll(null,"id DESC","id,title,content,picurl","0,2");
            $this->youjiinfo_result=$youjiinfo->findAll(null,"id DESC","id,username,title,releasedate","2,8");
//            dump($this->youjiinfo_result_top);
            //dump($this->youjiinfo_result);
		   $this -> display('xiamen.html'); // 厦门首页
		}
		//$this -> display('content/scenery.html');
	}
}
